<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='global-property-'>/**
</span> * @ignore
 * A seed where KISSY grows up from, KISS Yeah !
 * @author https://github.com/kissyteam/kissy/contributors
 */

<span id='KISSY'>/**
</span> * The KISSY global namespace object. you can use
 *
 *
 *      KISSY.each/mix
 *
 * to do basic operation. or
 *
 *
 *      KISSY.use('overlay,node', function(S, Overlay, Node){
 *          //
 *      });
 *
 * to do complex task with modules.
 * @singleton
 * @class KISSY
 */
var KISSY = (function (undefined) {
    var host = this,
        S,
        guid = 0,
        EMPTY = '';

    var loggerLevel = {
        'debug': 10,
        'info': 20,
        'warn': 30,
        'error': 40
    };

    S = {
<span id='KISSY-property-__BUILD_TIME'>        /**
</span>         * The build time of the library.
         * NOTICE: '@TIMESTAMP@' will replace with current timestamp when compressing.
         * @private
         * @type {String}
         */
        __BUILD_TIME: '@TIMESTAMP@',

<span id='KISSY-property-Env'>        /**
</span>         * KISSY Environment.
         * @private
         * @type {Object}
         */
        Env: {
            host: host
        },

<span id='KISSY-property-Config'>        /**
</span>         * KISSY Config.
         * If load kissy.js, Config.debug defaults to true.
         * Else If load kissy-min.js, Config.debug defaults to false.
         * @private
         * @property {Object} Config
         * @property {Boolean} Config.debug
         * @member KISSY
         */
        Config: {
            debug: '@DEBUG@',
            fns: {}
        },

<span id='KISSY-property-version'>        /**
</span>         * The version of the library.
         * NOTICE: '@VERSION@' will replace with current version when compressing.
         * @type {String}
         */
        version: '@VERSION@',

<span id='KISSY-method-config'>        /**
</span>         * set KISSY configuration
         * @param {Object|String} configName Config object or config key.
         * @param {String} configName.base KISSY 's base path. Default: get from kissy(-min).js or seed(-min).js
         * @param {String} configName.tag KISSY 's timestamp for native module. Default: KISSY 's build time.
         * @param {Boolean} configName.debug whether to enable debug mod.
         * @param {Boolean} configName.combine whether to enable combo.
         * @param {Object} configName.logger logger config
         * @param {Object[]} configName.logger.excludes  exclude configs
         * @param {Object} configName.logger.excludes.0 a single exclude config
         * @param {RegExp} configName.logger.excludes.0.logger  matched logger will be excluded from logging
         * @param {KISSY.Logger.Level} configName.logger.excludes.0.minLevel  minimum logger level
         * @param {KISSY.Logger.Level} configName.logger.excludes.0.maxLevel  maximum logger level
         * @param {Object[]} configName.logger.includes include configs
         * @param {Object} configName.logger.includes.0 a single include config
         * @param {RegExp} configName.logger.includes.0.logger  matched logger will be included from logging
         * @param {KISSY.Logger.Level} configName.logger.excludes.0.minLevel  minimum logger level
         * @param {KISSY.Logger.Level} configName.logger.excludes.0.maxLevel  maximum logger level
         * @param {Object} configName.packages Packages definition with package name as the key.
         * @param {String} configName.packages.base Package base path.
         * @param {String} configName.packages.tag  Timestamp for this package's module file.
         * @param {String} configName.packages.debug Whether force debug mode for current package.
         * @param {String} configName.packages.combine Whether allow combine for current package modules.
         * @param {String} [configName.packages.ignorePackageNameInUri=false] whether remove packageName from module request uri,
         * can only be used in production mode.
         * @param {Array[]} configName.map file map      File url map configs.
         * @param {Array[]} configName.map.0     A single map rule.
         * @param {RegExp} configName.map.0.0    A regular expression to match url.
         * @param {String|Function} configName.map.0.1   Replacement for String.replace.
         * @param [configValue] config value.
         *
         * for example:
         *     @example
         *     KISSY.config({
         *      combine: true,
         *      base: '',
         *      packages: {
         *          'gallery': {
         *              base: 'http://a.tbcdn.cn/s/kissy/gallery/'
         *          }
         *      },
         *      modules: {
         *          'gallery/x/y': {
         *              requires: ['gallery/x/z']
         *          }
         *      }
         *     });
         */
        config: function (configName, configValue) {
            var cfg,
                r,
                self = this,
                fn,
                Config = S.Config,
                configFns = Config.fns;
            if (S.isObject(configName)) {
                S.each(configName, function (configValue, p) {
                    fn = configFns[p];
                    if (fn) {
                        fn.call(self, configValue);
                    } else {
                        Config[p] = configValue;
                    }
                });
            } else {
                cfg = configFns[configName];
                if (configValue === undefined) {
                    if (cfg) {
                        r = cfg.call(self);
                    } else {
                        r = Config[configName];
                    }
                } else {
                    if (cfg) {
                        r = cfg.call(self, configValue);
                    } else {
                        Config[configName] = configValue;
                    }
                }
            }
            return r;
        },

<span id='KISSY-method-log'>        /**
</span>         * Prints debug info.
         * @param msg {String} the message to log.
         * @param {String} [cat] the log category for the message. Default
         *        categories are 'info', 'warn', 'error', 'time' etc.
         * @param {String} [logger] the logger of the the message (opt)
         */
        log: function (msg, cat, logger) {
            if ('@DEBUG@') {
                var matched = 1;
                if (logger) {
                    var loggerCfg = S.Config.logger || {},
                        list, i, l, level, minLevel, maxLevel, reg;
                    cat = cat || 'debug';
                    level = loggerLevel[cat] || loggerLevel['debug'];
                    if (list = loggerCfg.includes) {
                        matched = 0;
                        for (i = 0; i &lt; list.length; i++) {
                            l = list[i];
                            reg = l.logger;
                            maxLevel = loggerLevel[l.maxLevel] || loggerLevel['error'];
                            minLevel = loggerLevel[l.minLevel] || loggerLevel['debug'];
                            if (minLevel &lt;= level &amp;&amp; maxLevel &gt;= level &amp;&amp; logger.match(reg)) {
                                matched = 1;
                                break;
                            }
                        }
                    } else if (list = loggerCfg.excludes) {
                        matched = 1;
                        for (i = 0; i &lt; list.length; i++) {
                            l = list[i];
                            reg = l.logger;
                            maxLevel = loggerLevel[l.maxLevel] || loggerLevel['error'];
                            minLevel = loggerLevel[l.minLevel] || loggerLevel['debug'];
                            if (minLevel &lt;= level &amp;&amp; maxLevel &gt;= level &amp;&amp; logger.match(reg)) {
                                matched = 0;
                                break;
                            }
                        }
                    }
                    if (matched) {
                        msg = logger + ': ' + msg;
                    }
                }
                if (host['console'] !== undefined &amp;&amp; console.log &amp;&amp; matched) {
                    console[cat &amp;&amp; console[cat] ? cat : 'log'](msg);
                    return msg;
                }
            }
            return undefined;
        },

<span id='KISSY-method-getLogger'>        /**
</span>         * get log instance for specified logger
         * @param {String} logger logger name
         * @returns {KISSY.Logger} log instance
         */
        'getLogger': function (logger) {
            return getLogger(logger);
        },

<span id='KISSY-method-error'>        /**
</span>         * Throws error message.
         */
        error: function (msg) {
            if ('@DEBUG@') {
                // with stack info!
                throw msg instanceof  Error ? msg : new Error(msg);
            }
        },

        /*
         * Generate a global unique id.
         * @param {String} [pre] guid prefix
         * @return {String} the guid
         */
        guid: function (pre) {
            return (pre || EMPTY) + guid++;
        }
    };

    if ('@DEBUG@') {
        S.Config.logger = {
            excludes: [
                {
                    logger: /^s\/.*/,
                    maxLevel: 'info',
                    minLevel: 'debug'
                }
            ]
        };

<span id='KISSY-Logger'>        /**
</span>         * Log class for specified logger
         * @class KISSY.Logger
         * @private
         */
        function Logger() {

        }

<span id='KISSY-Logger-method-debug'>        /**
</span>         * print debug log
         * @method
         * @param {String} str log str
         */
        Logger.prototype.debug = function (str) {
        };
<span id='KISSY-Logger-method-info'>        /**
</span>         * print info log
         * @method
         * @param {String} str log str
         */
        Logger.prototype.info = function (str) {
        };
<span id='KISSY-Logger-method-warn'>        /**
</span>         * print warn log
         * @method
         * @param {String} str log str
         */
        Logger.prototype.warn = function (str) {
        };
<span id='KISSY-Logger-method-error'>        /**
</span>         * print error log
         * @method
         * @param {String} str log str
         */
        Logger.prototype.error = function (str) {
        };
    }

    function getLogger(logger) {
        var obj = {};
        S.each(loggerLevel, function (_, cat) {
            obj[cat] = function (msg) {
                return S.log(msg, cat, logger);
            };
        });
        return obj;
    }


<span id='KISSY-Logger-Level'>    /**
</span>     * Logger level enum
     * @enum {String} KISSY.Logger.Level
     */
<span id='global-property-'>    S.Logger = /**@type Function
</span>     @ignore */{};
    S.Logger.Level = {
<span id='KISSY-Logger-Level-property-DEBUG'>        /**
</span>         * debug level
         */
        'DEBUG': 'debug',
<span id='KISSY-Logger-Level-property-INFO'>        /**
</span>         * info level
         */
        INFO: 'info',
<span id='KISSY-Logger-Level-property-WARN'>        /**
</span>         * warn level
         */
        WARN: 'warn',
<span id='KISSY-Logger-Level-property-ERROR'>        /**
</span>         * error level
         */
        ERROR: 'error'
    };

    return S;
})();</pre>
</body>
</html>
